const app = getApp();
const _http = (url, method, data) => {
    return new Promise((resolve, reject) => {
        wx.request({
            url: `${app.globalData.baseUrl}${url}`,
            data: {
                ...data,
                wechatOpenId: wx.getStorageSync('openId')
            },
            method: method,
            // header: {
            //     token: wx.getStorageSync('token') || ''
            // },
            success: (e) => {
                if (e.data.resultCode === 1000) {
                    resolve(e);
                } else {
                    wx.hideLoading();
                    reject(e);
                }
            },
            fail: (e) => {
                console.log(e)
                wx.hideLoading();
                reject(e);
            }
        })
    });
}
module.exports = _http;